/**
 * Filename: ImageOptHelper.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/2/23 16:36
 */
package com.github.postsanf.yinian.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.backends.pipeline.PipelineDraweeController;
import com.facebook.drawee.controller.AbstractDraweeController;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.request.BasePostprocessor;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.github.postsanf.yinian.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

import java.util.Random;

public class ImageOptHelper {

    // 图片加载填充色
    public static int[] listimg = {R.color.load_random_1, R.color.load_random_2, R.color.load_random_3,
            R.color.load_random_4, R.color.load_random_5, R.color.load_random_6,
            R.color.load_random_7, R.color.load_random_8, R.color.load_random_9,
            R.color.load_random_10, R.color.load_random_11, R.color.load_random_12};

    public static void showFrescoImg(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 100), DisplayUtils.dp2px(mContext, 100)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoStatus(String url, ImageView draweeView, Context mContext) {
//        if (!url.endsWith(".gif")) {
//            DisplayImageOptions options = new DisplayImageOptions.Builder()
//                    .showImageOnLoading(ImageOptHelper.listimg[new Random().nextInt(12)])   // 设置图片下载期间显示的图片
////                .showImageForEmptyUri(Color.BLUE)  // 设置图片Uri为空或是错误的时候显示的图片
////                .showImageOnFail(Color.BLUE)       // 设置图片加载或解码过程中发生错误显示的图片
//                    .cacheInMemory(true)               // 设置下载的图片是否缓存在内存中
//                    .cacheOnDisc(true)                 // 设置下载的图片是否缓存在SD卡中
//                    .build();                         // 创建配置过得DisplayImageOption对象
//            ImageLoader.getInstance().displayImage(url, draweeView, options);
//        } else {
        Glide.with(mContext)
                .load(url)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .placeholder(ImageOptHelper.listimg[new Random().nextInt(12)])
                .into(draweeView);
//        }
    }

    public static void showImageLoaderTodayShow(String url, ImageView draweeView, Context mContext) {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(ImageOptHelper.listimg[new Random().nextInt(12)])   // 设置图片下载期间显示的图片
                .displayer(new RoundedBitmapDisplayer(UIHelper.dip2px(mContext, 5))) //设置图片圆角显示
                .cacheInMemory(true)               // 设置下载的图片是否缓存在内存中
                .cacheOnDisc(true)                 // 设置下载的图片是否缓存在SD卡中
                .build();                         // 创建配置过得DisplayImageOption对象
        ImageLoader.getInstance().displayImage(url, draweeView, options);
    }

    public static void showTransfer(String url, ImageView draweeView, Context mContext) {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(ImageOptHelper.listimg[new Random().nextInt(12)])   // 设置图片下载期间显示的图片
                .cacheInMemory(true)               // 设置下载的图片是否缓存在内存中
                .cacheOnDisc(true)                 // 设置下载的图片是否缓存在SD卡中
                .build();                         // 创建配置过得DisplayImageOption对象
        ImageLoader.getInstance().displayImage(url, draweeView, options);
    }

    public static void showImageLoaderLoMoPreView(String url, ImageView draweeView, Context mContext) {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(ImageOptHelper.listimg[new Random().nextInt(12)])   // 设置图片下载期间显示的图片
                .cacheInMemory(true)               // 设置下载的图片是否缓存在内存中
                .cacheOnDisc(true)                 // 设置下载的图片是否缓存在SD卡中
                .build();                         // 创建配置过得DisplayImageOption对象
        ImageLoader.getInstance().displayImage(url, draweeView, options);
    }

    public static void showFrescoStatus(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 90), DisplayUtils.dp2px(mContext, 90)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .setAutoPlayAnimations(true)
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoStatusSingle(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 360), DisplayUtils.dp2px(mContext, 360)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoSingeTimeCardCover(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 480), DisplayUtils.dp2px(mContext, 480)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoSingePic(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 270), DisplayUtils.dp2px(mContext, 270)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoNative(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 70), DisplayUtils.dp2px(mContext, 70)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoTimeMarks(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 480), DisplayUtils.dp2px(mContext, 480)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showSharePhoto(Uri uri, SimpleDraweeView draweeView, Context mContext, BaseControllerListener listener) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 70), DisplayUtils.dp2px(mContext, 70)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(listener)
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoBlur(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 184), DisplayUtils.dp2px(mContext, 184)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
    }


    public static void showFrescoHxImg(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 160), DisplayUtils.dp2px(mContext, 160)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoTimeLine(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 60), DisplayUtils.dp2px(mContext, 60)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoHome(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 184), DisplayUtils.dp2px(mContext, 184)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoAvatar(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 56), DisplayUtils.dp2px(mContext, 56)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
    }

    public static void showFrescoAvatar(String url, SimpleDraweeView draweeView, Context mContext) {
        Glide.with(mContext)
                .load(url)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .placeholder(ImageOptHelper.listimg[new Random().nextInt(12)])
                .into(draweeView);
    }

    public static void showHuanXinAvatar(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 56), DisplayUtils.dp2px(mContext, 56)))
                .setProgressiveRenderingEnabled(true)
                .build();

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoTodayshow(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
//				.setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 50), DisplayUtils.dp2px(mContext, 50)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
    }

    public static void showFrescoVoicePic(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 345), DisplayUtils.dp2px(mContext, 359)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
    }

    public static void showFrescoImport(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 50), DisplayUtils.dp2px(mContext, 50)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    public static void showFrescoCoverTheme(Uri uri, SimpleDraweeView draweeView, Context mContext) {
        ImageRequest imgRequest = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setResizeOptions(new ResizeOptions(DisplayUtils.dp2px(mContext, 200), DisplayUtils.dp2px(mContext, 200)))
                .setProgressiveRenderingEnabled(true)
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setImageRequest(imgRequest)
                .setAutoPlayAnimations(true)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener())
                .build();
        draweeView.setController(controller);
        GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
        hierarchy.setPlaceholderImage(listimg[new Random().nextInt(12)]);
    }

    // 首页Banner图加载
    public static DisplayImageOptions getBannerOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .delayBeforeLoading(100)
                .displayer(new FadeInBitmapDisplayer(300))
                .build();
        return imgOptions;
    }

    // 个人页面背景图
    public static DisplayImageOptions getBgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(listimg[new Random().nextInt(12)])
                .delayBeforeLoading(100)
                .displayer(new FadeInBitmapDisplayer(300)) // 展现方式：渐现
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getTimeLineOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(false)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT)
                .delayBeforeLoading(100)
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getLocalImgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(R.color.load_random_1)
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getNativeImgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(listimg[new Random().nextInt(12)])
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getDetailOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(listimg[new Random().nextInt(12)])
                .considerExifParams(true)
                .displayer(new FadeInBitmapDisplayer(300)) // 展现方式：渐现
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getImgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(false)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .considerExifParams(true)
                .displayer(new FadeInBitmapDisplayer(300)) // 展现方式：渐现
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getTransImgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(false)
                .cacheInMemory(false)
                .bitmapConfig(Bitmap.Config.ARGB_8888)
                .considerExifParams(true)
//                .displayer(new FadeInBitmapDisplayer(300)) // 展现方式：渐现
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getnormalOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(false)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .delayBeforeLoading(100)
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getUpImgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(listimg[new Random().nextInt(12)])
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getBlurOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .delayBeforeLoading(800)
                .displayer(new FadeInBitmapDisplayer(2000))
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getMeBlurOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .delayBeforeLoading(100)
                .displayer(new FadeInBitmapDisplayer(300))
                .build();
        return imgOptions;
    }

    public static DisplayImageOptions getListBgOptions() {
        DisplayImageOptions imgOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(listimg[new Random().nextInt(12)])
//				.showImageForEmptyUri(R.drawable.timeline_image_loading)
                .delayBeforeLoading(100)
                .displayer(new FadeInBitmapDisplayer(300))
                .resetViewBeforeLoading(true)
                .imageScaleType(ImageScaleType.EXACTLY)
                .build();
        return imgOptions;
    }

    //组头像
    public static DisplayImageOptions getAvatarGroupOptions() {
        DisplayImageOptions avatarOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
//				.showImageOnLoading(R.drawable.avatar_group)
//				.showImageForEmptyUri(R.drawable.avatar_group)
//				.showImageOnFail(R.drawable.avatar_group)
                .displayer(new RoundedBitmapDisplayer(999))
                .delayBeforeLoading(100)
                .build();
        return avatarOptions;
    }

    //圆形头像
    public static DisplayImageOptions getAvatarOptions() {
        DisplayImageOptions avatarOptions = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .showImageOnLoading(R.drawable.avatar_default)
//				.showImageForEmptyUri(R.drawable.avatar_default)
//				.showImageOnFail(R.drawable.avatar_default)
                .displayer(new RoundedBitmapDisplayer(999))
                .delayBeforeLoading(100)
//				.displayer(new FadeInBitmapDisplayer(300))
                .build();
        return avatarOptions;
    }

    public static DisplayImageOptions getCornerOptions(int cornerRadiusPixels) {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .cacheOnDisk(true)
                .cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565)
//			.showImageOnLoading(R.drawable.timeline_image_loading)
//			.showImageForEmptyUri(R.drawable.timeline_image_loading)
//			.showImageOnFail(R.drawable.timeline_image_loading)
                .displayer(new RoundedBitmapDisplayer(cornerRadiusPixels)).build();
        return options;
    }

}
